# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=virtualenv
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-virtualenv")
pkgver=20.4.4
pkgrel=1
pkgdesc="Virtual Python Environment builder (mingw-w64)"
url="https://virtualenv.pypa.io/"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python-appdirs"
         "${MINGW_PACKAGE_PREFIX}-python-distlib"
         "${MINGW_PACKAGE_PREFIX}-python-filelock"
         "${MINGW_PACKAGE_PREFIX}-python-six")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools-scm")
source=(${_realname}-${pkgver}.tar.gz::https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz)
sha256sums=('09c61377ef072f43568207dc8e46ddeac6bcdcaf288d49011bda0e7f4d38c4a2')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX})
  # fix python command in files
  for _f in "${pkgdir}${MINGW_PREFIX}"/bin/*.py; do
    sed -i 's/\#\!.*//' $_f
  done
  install -Dm644 LICENSE -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
